﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Directory.Web
{
    public partial class Admin_Controls_CategoryView : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!WebUtil.IsCurrentUserInRole(WebSettings.GetInstance().CategoryAdminRole))
            {
                this.Controls.Clear();
                this.Visible = false;
            }

            this.CategoryTree.UserName = Page.User.Identity.Name;
            this.CategoryTree.Target = this.Target;

            this.RolePanel.AllowRoles = WebSettings.GetInstance().RootCategoryAdminRole;
            if (CategoryDataProxy.GetCategoriesCount() == 0)
            {
                this.RolePanel.Visible = true;
            }
            else
            {
                this.RolePanel.Visible = false;
            }
        }

        private string _target;
        public string Target
        {
            get { return _target; }
            set { _target = value; }
        }
    }
}